/*
 * Developer : Jack Matthews
 * Email: developer@droidprofessor.com
 * 
 * Copyright (C) 2010 http://droidprofessor.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.droidprofessor.licensegenerator.lib;


import android.content.Context;
import android.provider.Settings;
import android.telephony.TelephonyManager;

/**
 * This is the interface you will use when loading the license
 * through.<br/><br/>
 * ClientLicense auth = LicenseLoader.getInstance();
 * <br/><br/>
 * <u>Notes on salt</u><br/>
 * the random salt String will help further 
 * randomize the encrypted data, this can be any string.
 * It should be fixed and <u>never</u> change between
 * versions of your application unless you wish to prevent
 * access to the newer version from users that have
 * paid for older versions. It would be wise to create a 
 * static final constant for the salt value and pass it
 * to all commands requiring the salt String.
 * <br/><br/>
 * If the users are able to upgrade for free <b>DO NOT</b> alter
 * the salt between versions.
 * 
 * @author Jack Matthews
 *
 */
public interface CoreClientLicense {

	
	/**
	 * Loads necessary data into memory.
	 * Should be called once when the application is first
	 * started.
	 * 
	 * @param base64PublicKey Base64 publicKey
	 * @param base64Signature Base64 license file Encrypted by the appKey
	 */
	public void init( byte[] base64PublicKey, byte[] base64Signature);
	
	
	/**
	 * Check that the phones device ID is equal to the license device ID
	 * 
	 * Returns the unique device ID, for example, the IMEI for GSM 
	 * and the MEID for CDMA phones. Return null if device ID is 
	 * not available. 
	 * 
	 * @return true if equal false otherwise
	 * @see Feature#DEVICE_ID
	 * 
	 */
	public boolean isDeviceIdEqual();
	
	/**
	 * Check that the phones 'phone numer' is equal to the license 'phone numer'
	 * 
	 * @return true if equal false otherwise
	 * @see Context#TELEPHONY_SERVICE
	 * @see TelephonyManager#getLine1Number()
	 * @see Feature#PHONE_NUMBER
	 */
	public boolean isPhoneNumberEqual();
	
	
	/**
	 * Check that the phones 'Android Boot ID' is equal to the license 'Android Boot ID'
	 * 
	 * A 64-bit number (as a hex string) that is randomly 
     * generated on the device's first boot and should remain 
     * constant for the lifetime of the device. 
     * (The value may change if a factory reset is performed on 
     * the device.) 
     * 
	 * @return true if equal false otherwise
	 * @see Settings.System#ANDROID_ID
	 * @see Feature#ANDROID_BOOT_ID
	 */
	public boolean isAndroidBootIdEqual();
	
    /**
     * Determine if the current license has <u>not</u> expired
     * 
     * @return true if still valid or false if expired
     * @see Feature#EXPIRY
     */
	public boolean isLicenseStillCurrent();
	
	
	
    /**
     * Determine if the application name is equal
     * 
     * @param appname the name of the application
     * @return true if equal
     * @see Feature#APPLICATION_ID
     */
	public boolean isApplicationIdEqual(String appname);


	
	/**
	 * The timestamp of license creation
	 * 
	 * @return timespamp
	 * @see Feature#TIMESTAMP
	 */
	public String getCreationTimestamp();
	
	
	
	/**
	 * The system used to create the license
	 * 
	 * @return phonelicenses.v1
	 * @see Feature#LICENSING_SYSTEM
	 */
	public String getLicensingSystem();
	
	
	
	/**
	 * Return the Joomla username that was used to create the license
	 * 
	 * @return username
	 * @see Feature#USERNAME
	 */
	public String getUsername();

	
	
	
	/**
	 * Get the expiry date
	 * 
	 * @return long expiry
	 */
	public long getExpiry();
	
	
//	//For JUnit Tests, accessible inside the package only
//	String getJUnitDeviceId();
//	String getJUnitUsername();
}
